%% Analysis of Steady-State 25C vs. 37C BarSeq data from Feb. 18 2021 samples
load('EcoliBW25113_Tn_LB_steadystate_20200218.mat');
temp = Downshifts_Feb18;
close all;

%% Create plotting arrays
time_37to37C = [-10 0 10 20 30 40 60 90];
fitness_array_37to37C = [temp.setAIT019218_37to37_10min_B temp.setAIT020218_37to37_0min_B temp.setAIT021218_37to37_10min_B temp.setAIT022218_37to37_20min_B temp.setAIT023218_37to37_30min_B temp.setAIT024218_37to37_40min_B temp.setAIT025218_37to37_60min_B temp.setAIT026218_37to37_90min_B];

time_37to25C = [-10 10 20 30 40 60 90];
fitness_array_37to25C = [temp.setAIT028218_37to25_10min_B temp.setAIT030218_37to25_10min_B temp.setAIT031218_37to25_20min_B temp.setAIT032218_37to25_30min_B temp.setAIT033218_37to25_40min_B temp.setAIT034218_37to25_60min_B temp.setAIT035218_37to25_90min_B];

%% Plot 37to37C data
hits_37to37C = [];

figure;
for k=1:size(fitness_array_37to37C,1)
    if mean(abs(fitness_array_37to37C(k,:)))<1
        plot(time_37to37C, fitness_array_37to37C(k,:), 'color', [0 0 0]+0.8);
    else
        plot(time_37to37C, fitness_array_37to37C(k,:), 'r');
        hits_37to37C = [hits_37to37C; k];
        text(time_37to37C(end), fitness_array_37to37C(k,end), temp.genename(k));
    end
    hold on;
end
ylim([-6 2]);
set(gcf, 'Position', [0 0 400 300]);
set(gca,'fontsize', 20);
box off;
xlabel('Time (min)');
ylabel('Log2 fitness');

%% Plot 37to25C data
hits_37to25C = [];

figure;
for k=1:size(fitness_array_37to25C,1)
    if mean(abs(fitness_array_37to25C(k,:)))<1
        plot(time_37to25C, fitness_array_37to25C(k,:), 'color', [0 0 0]+0.8);
    else
        plot(time_37to25C, fitness_array_37to25C(k,:), 'b');
        hits_37to25C = [hits_37to25C; k];
        text(time_37to25C(end), fitness_array_37to25C(k,end), temp.genename(k));
    end
    hold on;
end
ylim([-6 2]);
set(gcf, 'Position', [0 0 400 300]);
set(gca,'fontsize', 20);
box off;
xlabel('Time (min)');
ylabel('Log2 fitness');

%% Display hits
disp('37 to 37 hits');
temp.genename(hits_37to37C)
disp('37 to 25 hitsL');
temp.genename(hits_37to25C)